package com.csd.homework3;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    private Repository repository;
    @RequestMapping("/findByBrand")
    public Product findByBrand(@PathVariable("brand") String brand){
        return repository.findByBrand(brand);
    }
    @RequestMapping("/{id}")
    public Product findOneById(@PathVariable("id") int id){
        return repository.findById(id).get();
    }
    @RequestMapping("/delete/{Id}")
    public String deleteById(@PathVariable int id) {
        repository.deleteById(id);
        return "product" + id + "deleted successfully";
    }
}
